package br.com.winesys.geta.databinding.component.table.editors;

import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
import br.com.winesys.geta.databinding.Binder;

public final class FrameworkCellEditor extends AbstractCellEditor implements TableCellEditor {

	private JComponent component;

	public FrameworkCellEditor(JComponent component) {
		this.component = component;
	}

	@Override
	public Object getCellEditorValue() {
		return Binder.getInstance().getComponentValue(this.component);
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
		Binder.getInstance().setComponentValue(this.component, value);
		return this.component;
	}
}
